import { createApp } from 'vue'
import piniaPlugin from "pinia-plugin-persistedstate";
import { createPinia } from 'pinia'
import 'element-plus/dist/index.css' //引入消息样式
import '@/router/dynamicRouter'  //引入动态路由
import App from './App.vue'
import '../public/iconfont/iconfont.css'  //引入阿里图标
import { i18n } from "@/i18n";
import router from './router'
import { useUserStore } from "@/stores/admin";
import 'nprogress/nprogress.css' 


const app = createApp(App)
const pinia = createPinia()

pinia.use(piniaPlugin)
app.use(router)
app.use(pinia)
app.use(i18n)
app.mount('#app')


//自定义指令--权限按钮
app.directive('permission', {
    mounted(el, binding) {
        const store = useUserStore()
        let val = binding.value
        var permissionList = store.permissionList || []  //作用防止空指针异常
        let indexs = permissionList.indexOf("*")
        if(-1==indexs){
            console.log(val);
            if (-1 == permissionList.indexOf(val)) {
                //没有权限
                el.remove();
            }
        } 
    }
})